// ---------------------------- builds menu and retrieves values from GM------------------//
function buildmenus()
	{
	settingsButton = document.createElement("div");
		settingsButton.innerHTML = "open settings";
		//settingsButton.setAttribute("style", "position: absolute; left: 5px; top: 3px; font-family: tahoma; font-size: 10pt; font-weight: 600; -moz-user-select: none; -khtml-user-select: none; cursor: pointer;");
		settingsButton.setAttribute("style", "position: absolute; left: "+(bannerLeft+10)+"px; top: "+(bannerTop+25)+"px; font-family: tahoma; font-size: 10pt; font-weight: 600; -moz-user-select: none; -khtml-user-select: none; cursor: pointer; color: green;");
		settingsButton.addEventListener('click', toggleSettings, false);
		document.body.appendChild(settingsButton);

	viewLogButton = document.createElement("div");
		viewLogButton.innerHTML = "View Log";
		viewLogButton.setAttribute("style", "position: absolute; left: "+(bannerLeft+575)+"px; top: "+(bannerTop+25)+"px; font-family: tahoma; font-size: 10pt; font-weight: 600; -moz-user-select: none; -khtml-user-select: none; cursor: pointer;color: green;");
		viewLogButton.addEventListener('click', toggleLogBox, false);
		document.body.appendChild(viewLogButton);

	clrLogButton = document.createElement("div");
		clrLogButton.innerHTML = "Clear Log";
		clrLogButton.setAttribute("style", "position: absolute; left: "+(bannerLeft+575)+"px; top: "+(bannerTop+43)+"px; font-family: tahoma; font-size: 10pt; font-weight: 600; -moz-user-select: none; -khtml-user-select: none; cursor: pointer;color: green;");
		clrLogButton.addEventListener('click', clearLog, false);
		document.body.appendChild(clrLogButton);

	settingsBox = document.createElement("div");
		if (settingsOpen == true)
			{
			settingsBox.setAttribute("style", "position: absolute; left: "+bannerLeft+"px; top: "+(bannerTop+43)+"px; width: 560px; height: 500px; background-color: #01011B; font-family: tahoma; font-size: 10pt; text-align: left; padding: 5px; border: 1px dotted; visibility: visible; z-index: 100;");
			}
		else
			{
			settingsBox.setAttribute("style", "position: absolute; left: "+bannerLeft+"px; top: "+(bannerTop+43)+"px; width: 560px; height: 500px; background-color: #01011B; font-family: tahoma; font-size: 10pt; text-align: left; padding: 5px; border: 1px dotted; visibility: hidden; z-index: 100;");
			}
		document.body.appendChild(settingsBox);
	
	logBox = document.createElement("div");
		logBox.innerHTML = GM_getValue('itemLog', 'log empty');
		if (logOpen == true)
			{
			logBox.setAttribute("style", "position: absolute; overflow: scroll; left: "+bannerLeft+"px; top: "+(bannerTop+28)+"px; width: 600px; height: 400px; background-color: #01011B;color:white; font-family: tahoma; font-size: 8pt; text-align: left; padding: 5px; border: 1px dotted; visibility: visible; z-index: 999999;");
			}
		else 
			{
			logBox.setAttribute("style", "position: absolute; overflow: scroll; left: "+bannerLeft+"px; top: "+(bannerTop+28)+"px; width: 600px; height: 400px; background-color: #01011B;color:white; font-family: tahoma; font-size: 8pt; text-align: left; padding: 5px; border: 1px dotted; visibility: hidden; z-index: 999999;");
			}
		document.body.appendChild(logBox);
		
	fightBox = document.createElement("div");
		fightBox.setAttribute("style", "position: absolute; overflow: scroll; left: "+bannerLeft+"px; top: "+(bannerTop+28)+"px; width: 600px; height: 400px; background-color: #01011B;color:white; font-family: tahoma; font-size: 8pt; text-align: left; padding: 5px; border: 1px dotted; visibility: hidden; z-index: 999999;");
		document.body.appendChild(fightBox);
		
	if(SCRIPT.appID=='app16421175101') //if this is the pirates script
		{
		versionBox = document.createElement("div");
			versionBox.innerHTML  = "<img src='http://www.zynga.com/images/games/gameSmall_pirates.jpg'/><strong> "+SCRIPT.version+" </strong>";
			versionBox.setAttribute("style", "position: absolute; color: #FFFFFF;");
			settingsBox.appendChild(versionBox);
		}
	else if (SCRIPT.appID=='app97498830044') //if this is the heroes script
		{
		versionBox = document.createElement("div");
			versionBox.innerHTML  = "<img src='http://www.zynga.com/images/games/gameSmall_heroesvsvillains.jpg'/><strong> "+SCRIPT.version+" </strong>";
			versionBox.setAttribute("style", "position: absolute; color: #FFFFFF;");
			settingsBox.appendChild(versionBox);
		}
	else if (SCRIPT.appID=='app36842288331') //if this is the spacewares script
		{
		versionBox = document.createElement("div");
			versionBox.innerHTML  = "<img src='http://www.zynga.com/images/games/gameSmall_spacewars.jpg'/><strong> "+SCRIPT.version+" </strong>";
			versionBox.setAttribute("style", "position: absolute; color: #FFFFFF;");
			settingsBox.appendChild(versionBox);
		}
		
	autoClick = document.createElement("div");
		autoClick.innerHTML  = "<input type='checkbox' id='autoClick' value='checked' "+GM_getValue('autoClick', '')+">enable auto-refresh";
		autoClick.setAttribute("style", "position: absolute; top: 100px; color: #FFFFFF;");
		settingsBox.appendChild(autoClick);

	refreshTimes = document.createElement("div");
		refreshTimes.innerHTML  = "refresh every <input type='text' style='border: none; text-align: center; background-color: #EEEEEE;' value='"+GM_getValue('r1', '30')+"' id='r1' size='2'>";
		refreshTimes.innerHTML += " to <input type='text' style='border: none; text-align: center; background-color: #EEEEEE;' value='"+GM_getValue('r2', '110')+"'id='r2' size='2'> seconds";
		refreshTimes.setAttribute("style", "position: absolute; top: 125px;color: #FFFFFF;");
		settingsBox.appendChild(refreshTimes);

	autoProperty = document.createElement("div");
		autoProperty.innerHTML  = "<input type='checkbox' id='autoProperty' value='checked' "+GM_getValue('autoProperty', '')+">enable autobuy Properties";
		autoProperty.setAttribute("style", "position: absolute; top: 150px;color: #FFFFFF;");
		settingsBox.appendChild(autoProperty);

	autoMission = document.createElement("div");
		autoMission.innerHTML  = "<input type='checkbox' id='autoMission' value='checked' "+GM_getValue('autoMission', '')+">enable auto-Mission";
		autoMission.setAttribute("style", "position: absolute; top: 175px;color: #FFFFFF;");
		settingsBox.appendChild(autoMission);

	missionMastery = document.createElement("div");
		missionMastery.innerHTML  = "<input type='checkbox' id='missionMastery' value='checked' "+GM_getValue('missionMastery', '')+">Tier Mastery";
		missionMastery.setAttribute("style", "position: absolute; left:160px; top: 175px;color: #FFFFFF;");
		settingsBox.appendChild(missionMastery);

	selectMission = document.createElement("select");
		for each (var mission in missions )
			{
			if (mission[3]==0)
				{
				//Tab header creation
				var choiceTab = document.createElement('optgroup');
				tabtocreate = mission[2];
				choiceTab.label = missionTabs[tabtocreate-1];
				selectMission.appendChild(choiceTab);
				}
			choice = document.createElement('option');
			choice.value = mission[0];
			choice.appendChild(document.createTextNode(mission[0]));
			selectMission.appendChild(choice);
			}
		selectMission.selectedIndex = GM_getValue('selectMission', 1)
		selectMission.setAttribute("style", "position: absolute; top: 200px;");
		settingsBox.appendChild(selectMission);

	autoBank = document.createElement("div");
		autoBank.innerHTML  = "<input type='checkbox' id='autoBank' value='checked' "+GM_getValue('autoBank', '')+">enable auto-Bank";
		autoBank.setAttribute("style", "position: absolute; top: 235px;color: #FFFFFF;");
		settingsBox.appendChild(autoBank);

	bankConfig = document.createElement("div");
		bankConfig.innerHTML = "Minimum: <input type='text' style='border: none; width: 75px; text-align: center; background-color: #EEEEEE;' value='"+GM_getValue('bankConfig', '100000')+"' id='bankConfig' size='5'>";
		bankConfig.setAttribute("style", "position: absolute; top: 260px;left: 5px;color: #FFFFFF;");
		settingsBox.appendChild(bankConfig);

	bankKeep = document.createElement("div");
		bankKeep.innerHTML = "Keep: <input type='text' style='border: none; width: 75px; text-align: center; background-color: #EEEEEE;' value='"+GM_getValue('bankKeep', '50000')+"' id='bankKeep' size='5'>";
		bankKeep.setAttribute("style", "position: absolute; top: 260px;left: 150px;color: #FFFFFF;");
		settingsBox.appendChild(bankKeep);

	autoHeal = document.createElement("div");
		autoHeal.innerHTML  = "<input type='checkbox' id='autoHeal' value='checked' "+GM_getValue('autoHeal', 'checked')+">enable auto-Heal";
		autoHeal.setAttribute("style", "position: absolute; top:285px;color: #FFFFFF;");
		settingsBox.appendChild(autoHeal);

	healthLevel = document.createElement("div");
		healthLevel.innerHTML = "Heal Health: <input type='text' style='border: none; width: 30px; text-align: center; background-color: #EEEEEE;' value='"+GM_getValue('healthLevel', '50')+"' id='healthLevel' size='1'>";
		healthLevel.setAttribute("style", "position: absolute; top: 310px;color: #FFFFFF;");
		settingsBox.appendChild(healthLevel);

	healthRage = document.createElement("div");
		healthRage.innerHTML = "max. Strength: <input type='text' style='border: none; width: 30px; text-align: center; background-color: #EEEEEE;' value='"+GM_getValue('healthRage', '5')+"' id='healthRage' size='1'>";
		healthRage.setAttribute("style", "position: absolute; left: 120px;;top: 310px;color: #FFFFFF;");
		settingsBox.appendChild(healthRage);

	forceHealHealth = document.createElement("div");
		forceHealHealth.innerHTML = "Force Heal Health: <input type='text' style='border: none; width: 30px; text-align: center; background-color: #EEEEEE;' value='"+GM_getValue('forceHealHealth', '50')+"' id='forceHealHealth' size='1'>";
		forceHealHealth.setAttribute("style", "position: absolute; top: 335px;left: 5px;color: #FFFFFF;");
		settingsBox.appendChild(forceHealHealth);

	updateButton = document.createElement("div");
		updateButton.innerHTML  = "<button>check for updates</button>";
		updateButton.addEventListener('click', updateScript, false);
		updateButton.setAttribute("style", "position: absolute; top: 435px;");
		settingsBox.appendChild(updateButton);

	autoFight = document.createElement("div");
		autoFight.innerHTML  = "<input type='checkbox' id='autoFight' value='checked' "+GM_getValue('autoFight', '')+">enable auto-Fight above";
		autoFight.setAttribute("style", "position: absolute; left: 340px;top: 5px;color: #FFFFFF;");
		settingsBox.appendChild(autoFight);
        
	fightMinimum = document.createElement("div");
		fightMinimum.innerHTML  = "<input type='text' style='border: none; text-align: center; background-color: #EEEEEE;' value='"+GM_getValue('fightMinimum', '0')+"' id='fightMinimum' size='2'>";
		fightMinimum.setAttribute("style", "position: absolute; left:505px; top: 8px;color: #FFFFFF;");
		settingsBox.appendChild(fightMinimum);

	fightRandom = document.createElement("div");
		fightRandom.innerHTML  = "<input type='radio' name='r1' id='fightRandom' value='checked' "+GM_getValue('fightRandom', '')+"> fight random";
		fightRandom.setAttribute("style", "position: absolute; left: 340px; top: 30px;color: #FFFFFF;");
		settingsBox.appendChild(fightRandom);

	fightLevel = document.createElement("div");
		fightLevel.innerHTML = "max. level: <input type='text' style='border: none; width: 30px; text-align: center; background-color: #EEEEEE;' value='"+GM_getValue('fightLevel', '100')+"' id='fightLevel' size='1'>";
		fightLevel.setAttribute("style", "position: absolute; left: 340px; top: 55px;color: #FFFFFF;");
		settingsBox.appendChild(fightLevel);

	fightClanSize = document.createElement("div");
		fightClanSize.innerHTML = "max. Crew: <input type='text' style='border: none; width: 30px; text-align: center; background-color: #EEEEEE;' value='"+GM_getValue('fightClanSize', '502')+"' id='fightClanSize' size='1'>";
		fightClanSize.setAttribute("style", "position: absolute; left: 440px;top: 55px;color: #FFFFFF;");
		settingsBox.appendChild(fightClanSize);

	freshMeat = document.createElement("div");
		freshMeat.innerHTML  = "<input type='radio' name='r1' id='freshMeat' value='checked' "+GM_getValue('freshMeat', '')+"> go for fresh Meat";
		freshMeat.setAttribute("style", "position: absolute; left: 340px; top: 80px;color: #FFFFFF;");
		settingsBox.appendChild(freshMeat);

	fightList = document.createElement("div");
		fightList.innerHTML  = "<input type='radio' name='r1' id='rFightList' value='checked' "+GM_getValue('rFightList', '')+"> fight list:<br /><textarea style='border: none; background-color: #EEEEEE; width: 180px; height: 100px;' id='fightList'>"+GM_getValue('fightList', '')+"</textarea>";
		fightList.setAttribute("style", "position: absolute; left: 340px;top: 105px;color: #FFFFFF;");
		settingsBox.appendChild(fightList);

	if(SCRIPT.appID=='app16421175101') //if this is the pirates script
		{
		autoTreasure = document.createElement("div");
			autoTreasure.innerHTML  = "<input type='checkbox' id='autoTreasure' value='checked' "+GM_getValue('autoTreasure', '')+">enable auto-Treasure";
			autoTreasure.setAttribute("style", "position: absolute; left: 340px;top: 240px;color: #FFFFFF;");
			settingsBox.appendChild(autoTreasure);
		}

	autoPet = document.createElement("div");
		autoPet.innerHTML  = "<input type='checkbox' id='autoPet' value='checked' "+GM_getValue('autoPet', '')+">enable auto-Pet";
		autoPet.setAttribute("style", "position: absolute; left: 340px;top: 260px;color: #FFFFFF;");
		settingsBox.appendChild(autoPet);

	autoStats = document.createElement("div");
		autoStats.innerHTML  = "<input type='checkbox' id='autoStats' value='checked' "+GM_getValue('autoStats', '')+">enable auto-Stat Upgrade";
		autoStats.setAttribute("style", "position: absolute; left: 340px;top: 280px;color: #FFFFFF;");
		settingsBox.appendChild(autoStats);

	statAtt = document.createElement("div");
		statAtt.innerHTML  = "<input type='radio' name='statUpgrade' id='statAtt' value='attack' "+((GM_getValue('statUpgrade','')=='attack') ? 'checked' : '')+"> Attack";
		statAtt.setAttribute("style", "position: absolute; left: 340px; top: 300px;color: #FFFFFF;");
		settingsBox.appendChild(statAtt);

	statDef = document.createElement("div");
		statDef.innerHTML  = "<input type='radio' name='statUpgrade' id='statDef' value='defense' "+((GM_getValue('statUpgrade','')=='defense') ? 'checked' : '')+"> Defense";
		statDef.setAttribute("style", "position: absolute; left: 400px; top: 300px;color: #FFFFFF;");
		settingsBox.appendChild(statDef);
	
	statEnergy = document.createElement("div");
		statEnergy.innerHTML  = "<input type='radio' name='statUpgrade' id='statEnergy' value='max_energy' "+((GM_getValue('statUpgrade','')=='max_energy') ? 'checked' : '')+"> Energy";
		statEnergy.setAttribute("style", "position: absolute; left: 470px; top: 300px;color: #FFFFFF;");
		settingsBox.appendChild(statEnergy);
   
	statHP = document.createElement("div");
		statHP.innerHTML  = "<input type='radio' name='statUpgrade' id='statHP' value='max_health' "+((GM_getValue('statUpgrade','')=='max_health') ? 'checked' : '')+"> Health";
		statHP.setAttribute("style", "position: absolute; left: 340px; top: 320px;color: #FFFFFF;");
		settingsBox.appendChild(statHP);
	
	statStrength = document.createElement("div");
		statStrength.innerHTML  = "<input type='radio' name='statUpgrade' id='statStrength' value='max_stamina' "+((GM_getValue('statUpgrade','')=='max_stamina') ? 'checked' : '')+"> Strength (2 points)";
		statStrength.setAttribute("style", "position: absolute; left: 400px; top: 320px;color: #FFFFFF;");
		settingsBox.appendChild(statStrength);

	buyCrewProperty = document.createElement("div");
		buyCrewProperty.innerHTML  = "<input type='checkbox' id='buyCrewProperty' value='checked' "+GM_getValue('buyCrewProperty', '')+">enable Buy Crew Property";
		buyCrewProperty.setAttribute("style", "position: absolute; left: 340px;top: 360px;color: #FFFFFF;");
		settingsBox.appendChild(buyCrewProperty);

	buyCrewPropertyUnique = document.createElement("div");
		buyCrewPropertyUnique.innerHTML  = "<input type='checkbox' id='buyCrewPropertyUnique' value='checked' "+GM_getValue('buyCrewPropertyUnique', '')+">Only Buy Unique Crew Properties";
		buyCrewPropertyUnique.setAttribute("style", "position: absolute; left: 340px;top: 380px;color: #FFFFFF;");
		settingsBox.appendChild(buyCrewPropertyUnique);

	if(SCRIPT.appID=='app16421175101') //if this is the pirates script
		{
		autoIsland = document.createElement("div");
			autoIsland.innerHTML  = "<input type='checkbox' id='autoIsland' value='checked' "+GM_getValue('autoIsland', '')+">enable auto-Island (store/hire)";
			autoIsland.setAttribute("style", "position: absolute; left: 340px;top: 340px;color: #FFFFFF;");
			settingsBox.appendChild(autoIsland);
		}
	
	saveButton = document.createElement("div");
		saveButton.innerHTML  = "<button>save settings</button>";
		saveButton.addEventListener('click', saveSettings, false);
		saveButton.setAttribute("style", "position: absolute;left: 150px; top: 435px;");
		settingsBox.appendChild(saveButton);

	saveNotification = document.createElement("div");
		saveNotification.innerHTML = "<strong>Settings Saved</strong>";
		saveNotification.setAttribute("style","position: absolute;left:220px;top:380px;color:red;visibility:hidden;font-size:16px;");
		settingsBox.appendChild(saveNotification);
	}
